import Ind
import pandas as pd

data = pd.read_excel('data.xlsx')
kdj = Ind.KDJ(data, 9)

k=kdj[0]
d=kdj[1]
j=kdj[2]

from pyecharts import options as opts
from pyecharts.charts import Kline, Line

x_data = data['Trddt'].tolist()
y_data = data[['Opnprc'], ['Clsprc'], ['Loprc'], ['Hiprc']].apply(lambda i: [i[0], i[1], i[2], i[3]], axis=1).tolist

c = (
    Kline()
    .add_xaxis(x_data[:50])
    .add_yaxis("Kline", y_data[:50], yaxis_index=1)
    .set_global_opts(
        yaxis_opts=opts.AxisOpts(is_scale=True),
        xaxis_opts=opts.AxisOpts(is_scale=True),
        title_opts=opts.TitleOpts(title="Kline-基本示例"),
)
    #.render("Kline_base.html")
    .extend_axis(yaxis=opts.AxisOpts(name="K线", min_=min(data.loc[:50, 'Loprc']), max_=max(data.loc[:50, 'Hiprc'])))
)

line = Line()
line.add_xaxis(x_data[:50])
line.add_yaxis('k', k)
line.add_yaxis('d', d)
line.add_yaxis('j', j)
line.render("kdj.html")
line.set_series_opts(opts.LabelOpts(is_show=False), markpoint_opts=opts.MarkLineOpts(
    data = [
        opts.MarkLineItem(y=0.2, name="超卖"),
        opts.MarkLineItem(y=0.5, name="震荡"),
        opts.MarkLineItem(y=0.8, name="超买"),
    ]))
#line.set_global_opts(opts.LabelOpts(is_show=False))
c.overlap(line)
c.render("Kline_base.html")